var list = {
  typeId: '',
  number: 10,
  total: 0,
  totalPage: 0,
  page: 1,
  init: function (typeId) {
    if (!typeId) return
    this.typeId = typeId
    this.getData()
    this.renderPage()
  },
  getData: function () {
    var data = getVodListByTypeId({ 
      TYPEID: this.typeId, 
      STATION: this.page,
      LENGTH: this.number
    })
    page.data.goods = data.data
    this.total = data.total
    this.render()
    this.renderPage()
  },
  renderPage: function(){
    this.totalPage = Math.ceil(this.total / this.number)
    $('#page').html('第<span class="color">' + this.page + '</span>页 / 共<span class="color">' + this.totalPage + '</span>页')
  },
  render: function () {
    var html = ''
    for (var i = 0, l = page.data.goods.length; i < l; i++) {
      var data = page.data.goods[i]
      var img = data.picture[0].picPath90
      var style = ''
      if (i < 5) {
        style += 'top: 0;'
      } else {
        style += 'top: 310px;'
      }
      style += 'left:' + (i % 5) * 242 + 'px;'
      html += '<div id="list-' + i + '" class="item goods-item" style="' + style + '">'
      html += '<div class="img-container"><img src="' + img + '"/></div>'
      html += '<div class="info-container">'
      html += '<div class="name">' + data.name + '</div>'
      html += '<div class="price">兑换：<span class="color">' + data.price + '熊猫币</span></div>'
      html += '</div></div>'
    }
    $('#list').html(html)
  }
}